<#include "/includes/son.ftl">

<div class="container-fluid">
    <div class="card">
        <div class="card-header"><h4>修改分类</h4></div>
        <div class="card-body">
                <div class="form-group">
                    <input class="form-control" type="hidden"  id="typeId" name="typeId" <#if shopType??>value="${shopType.id}"</#if>>
                </div>
                <div class="form-group">
                    <label for="typeName">分类名称</label>
                    <input class="form-control" type="text" id="typeName" name="typeName" placeholder="请输入分类名称.." <#if shopType??>value="${shopType.typeName}"</#if> >
                </div>
                <div class="form-group">
                    <button class="btn btn-primary" id="btn" type="button"><#if shopType??>修改<#else>添加</#if></button>
                </div>
        </div>
    </div>
</div>
<script>
    $("#btn").click(function (){
        if ($("#typeId").val() == null){
            $.post("/goods/shopGoodsType/goodsTypeEdit",{id:$("#typeId").val(),typeName:$("#typeName").val()},function (res){
                if(res.status === 200){
                    lightyear.notify(res.data, 'success', 5000, 'mdi mdi-emoticon-happy', 'top', 'center');
                    window.location.href = document.referrer;
                }
                lightyear.notify(res.data, 'error', 5000, 'mdi', 'top', 'center');
            })
        }else {
            $.post("/goods/shopGoodsType/goodsTypeEdit",{id:$("#typeId").val(),typeName:$("#typeName").val()},function (res){
                if(res.status === 200){
                    lightyear.notify(res.data, 'success', 5000, 'mdi mdi-emoticon-happy', 'top', 'center');
                    window.location.href = document.referrer;
                }
                lightyear.notify(res.data, 'error', 5000, 'mdi', 'top', 'center');
            })
        }
    })
</script>